package com.tencent.examples.core.processor;

import com.alibaba.fastjson.JSONObject;
import com.tencent.bk.utils.blueking.properties.BluekingProperties;
import com.tencent.bk.utils.blueking.tools.HttpsClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author :  CHENWEN
 * @Description : 实例
 * @Creation Date:  2019/3/28
 */
@Component
public class InstConnect {
    @Autowired
    BluekingProperties properties;

    /**
     * 查询实例
     */
    private static final String SEARCH_INST = "/api/c/compapi/v2/cc/search_inst/";
    /**
     * 创建实例
     */
    private static final String CREATE_INST = "/api/c/compapi/v2/cc/create_inst/";
    /**
     * 更新实例
     */
    private static final String UPDATE_INST = "/api/c/compapi/v2/cc/update_inst/";
    /**
     * 更新门店的闭店时间ZABBIX
     */
    private static final String ZABBIX_API = "/api/c/self-service-api/zabbix_api/";

    /**
     * 查询实例
     *
     * @param jsonObject
     * @return
     */
    JSONObject searchInst(JSONObject jsonObject) {
        return HttpsClient.httpRequest(properties.getIp() + SEARCH_INST, "POST", jsonObject.toString());
    }

    /**
     * 新增实例
     *
     * @param jsonObject
     */
    JSONObject createInst(JSONObject jsonObject) {
        return HttpsClient.httpRequest(properties.getIp() + CREATE_INST, "POST", jsonObject.toString());
    }

    /**
     * 更新实例
     *
     * @param jsonObject
     */
    JSONObject updateInst(JSONObject jsonObject) {
        return HttpsClient.httpRequest(properties.getIp() + UPDATE_INST, "POST", jsonObject.toString());
    }

    /**
     * 更新门店闭店时间zabbix
     *
     * @param jsonObject
     */
    JSONObject updateZabbix(JSONObject jsonObject) {
        return HttpsClient.httpRequest(properties.getIp() + ZABBIX_API, "POST", jsonObject.toString());
    }
}
